import java.awt.image.RenderedImage;
import java.awt.image.renderable.ParameterBlock;
import javax.media.jai.Interpolation;
import javax.media.jai.JAI;
/*
 * ImageRotate.java
 *
 * Created on 7 de Fevereiro de 2005, 23:42
 */

/**
 *
 * @author Edison Puig Maldonado
 */

public class ImageRotate extends javax.swing.JPanel {
    
    /**
	 * 
	 */
	private static final long serialVersionUID = -4164192749250632012L;

	/** Creates new form ImageRotate */
    public ImageRotate() {
        initComponents();
    }
    
    public static RenderedImage rotateImage(final RenderedImage image, int X, int Y, double angulo) {
        ParameterBlock pb = new ParameterBlock();
        pb.addSource(image);                  // The source image
        pb.add(X*1.0F);                       // The x origin
        pb.add(Y*1.0F);                       // The y origin
        pb.add((float)angulo);                // The rotation angle
        pb.add(Interpolation.getInstance(Interpolation.INTERP_NEAREST));
        try {
        	return JAI.create("Rotate", pb);
        } catch (Exception e) {
        	 e.printStackTrace();
        	 return null;
        }
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents

        setLayout(new java.awt.BorderLayout());

    }//GEN-END:initComponents
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
    
}
